
export function TimeDiff(time) {
  const currentTime = new Date();
  const someTime = new Date(time);
  const timeDifference = Math.abs(currentTime - someTime);
  const min = Math.floor(timeDifference / (1000 * 60))
  if (min < 1) {
    return '刚刚';
  } else if (min < 30) {
    return `${min}分钟前`;
  } else if (min < 60) {
    return '半小时前';
  } else if (min >= 60) {
    const hour = Math.floor(min / 60);
    if (hour < 12) {
      return `${hour}小时前`;
    } else if (hour < 24) {
      return '半天前';
    } else {
      const day = Math.floor(hour / 24);
      if (day < 30) {
        return `${day}天前`;
      } else {
        const month = Math.floor(day / 30);
        return `${month}月前`;
      }
    }
  } else {
    const year = Math.floor(min / 525600);
    return `${year}年前`;
  }
}